package cn.wolfcode.car.business.web.controller;

import cn.wolfcode.car.base.domain.Dept;
import cn.wolfcode.car.base.domain.Post;
import cn.wolfcode.car.base.service.IDeptService;
import cn.wolfcode.car.base.service.IPostService;
import cn.wolfcode.car.business.domain.Appointment;
import cn.wolfcode.car.business.domain.Customer;
import cn.wolfcode.car.business.domain.Store;
import cn.wolfcode.car.business.query.StoreQuery;
import cn.wolfcode.car.business.service.ICustomerService;
import cn.wolfcode.car.business.service.IStoreService;
import cn.wolfcode.car.common.base.page.TablePageInfo;
import cn.wolfcode.car.common.web.AjaxResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 岗位控制器
 */
@Controller
@RequestMapping("business/store")
public class StoreController {
    //模板前缀
    private static final String prefix = "business/store/";

    @Autowired
    private IStoreService storeService;
    

    //页面------------------------------------------------------------
    //列表
    @RequiresPermissions("business:store:view")
    @RequestMapping("/listPage")
    public String listPage(Model model){
        return prefix + "list";
    }

    @RequiresPermissions("business:store:add")
    @RequestMapping("/addPage")
    public String addPage(){
        return prefix + "add";
    }


    //数据-----------------------------------------------------------
    //列表
    @RequiresPermissions("business:store:list")
    @RequestMapping("/query")
    @ResponseBody
    public TablePageInfo<Store> query(StoreQuery qo){
        return storeService.query(qo);
    }

    //新增
    @RequiresPermissions("business:store:add")
    @RequestMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Store store){
        storeService.save(store);
        return AjaxResult.success();
    }
    //编辑跳转
    @RequiresPermissions("business:store:edit")
    @RequestMapping("/editPage")
    public String editPage(Long id, Model model){
        model.addAttribute("store", storeService.get(id));
        return prefix + "edit";
    }

    //编辑操作
    @RequiresPermissions("business:store:edit")
    @RequestMapping("/edit")
    @ResponseBody
    public AjaxResult edit(Store store){
        storeService.update(store);
        return AjaxResult.success();
    }

    //删除(软删除)
    @RequiresPermissions("business:store:remove")
    @RequestMapping("/remove")
    @ResponseBody
    public AjaxResult remove(Long  ids){
        storeService.delete(ids);
        return AjaxResult.success();
    }


}
